#include "categorydialog.h"
#include "ui_categorydialog.h"
#include <QFileDialog>

CategoryDialog::CategoryDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::CategoryDialog), isAccepted(false)
{
    ui->setupUi(this);
}

CategoryDialog::~CategoryDialog()
{
    delete ui;
}

QString CategoryDialog::getName()
{
    return ui->lineEdit->text();
}

QString CategoryDialog::getDescription()
{
    return ui->lineEdit_2->text();
}
QString CategoryDialog::getImagePath()
{
    return ui->lineEdit_3->text();
}
QString CategoryDialog::getSoundPath()
{
    return ui->lineEdit_4->text();
}

void CategoryDialog::setName(const QString &value)
{
    ui->lineEdit->setText(value);
}
void CategoryDialog::setDescription(const QString &value)
{
    ui->lineEdit_2->setText(value);
}
void CategoryDialog::setImagePath(const QString &value)
{
    ui->lineEdit_3->setText(value);
}

void CategoryDialog::setSoundPath(const QString &value)
{
    ui->lineEdit_4->setText(value);
}

void CategoryDialog::on_buttonBox_accepted()
{
    isAccepted = true;
}

void CategoryDialog::on_buttonBox_rejected()
{
    isAccepted = false;
}

void CategoryDialog::on_pushButton_clicked()
{
    QString path = QFileDialog::getOpenFileName(this, tr("Open Image File"), "", tr("PNG (*.png);;SVG (*.svg);;All Files (*.*)"));
    if (path.size())
    {
        setImagePath(path);
    }
}

void CategoryDialog::on_pushButton_2_clicked()
{
    QString path = QFileDialog::getOpenFileName(this, tr("Open Sound File"), "", tr("FLAC (*.flac);;All Files (*.*)"));
    if (path.size())
    {
        setSoundPath(path);
    }
}
